<?php

/**
 * Project: CrazyPoems
 * Author: Alexandru
// Traslate By: Christian :P
 * Date: 23/10/2008
 * File: poems.php
 */
// Load default settings.
require('inc/config.php');
require('inc/functions.misc.php');
require('inc/functions.index.php');

// Get parameters.
$category = $_GET['category'];
$search = $_GET['search'];
$breadcrumbs = '<a href="'.BASE_URL.'">'.l('Inicio').'</a>';

if (strlen($category) > 0) {
	$categoryName = getCategoryById($category);
	$breadcrumbs .=' &raquo; <a href="'.BASE_URL.'poems.php">'.l('Poesía').'</a> &raquo; '.$categoryName;
	$pageTitle = $categoryName;
	$selectedCategory = $category;
} else {
	$pageTitle = "Crazypoems - ".l('Todas las poesías');
	$breadcrumbs .=' &raquo; '.l('Todas las poesías');
}

$poems = getPoems($category, "", 10, $search);
if (isset($poems[0])) {
    $poemsTo = "left";
    $leftPoems = array();
    $rightPoems = array();
    for ($i = 0; $i < sizeof($poems); $i++) {
        if ($poemsTo == "left") {
           $leftPoems[] = $poems[$i];
           $poemsTo = "right";
        } else {
           $rightPoems[] = $poems[$i];
           $poemsTo = "left";
        }
    }
}
$smarty->assign('pageTitle', $pageTitle);
$smarty->assign('breadcrumbs', $breadcrumbs);
$smarty->assign('selectedCategory', $selectedCategory);
$smarty->assign('leftPoems', $leftPoems);
$smarty->assign('rightPoems', $rightPoems);
$smarty->assign('search', $search);
$smarty->assign('authors', getAllMembers());

$smarty->display('poems.tpl');

// End page.
require('inc/end.php');
?>
